package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBillStatus;
import com.bzkj.basicinfo.service.ncc.NccBillStatusService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@Api(tags = "单据状态")
@RestController
@RequestMapping("/ncc")
public class NccBillStatusController extends BaseController
{

    @Autowired
    private NccBillStatusService billStatusService;

    /**
     * NCC单据状态
     */
    @GetMapping({"/billStatus", "/billStatus/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:BillStatus:Job')")
    public void nccBillStatusJob(@PathVariable(required = false) String all)
    {
        billStatusService.updateNccBillStatusJob(all);
    }

    /**
     * 根据条件查询单据列表状态
     *
     * @Author wangzhichao
     * @Date 2024/12/10 09:56:42
     * @Param entity
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBillStatusData")
    public TableDataInfo findNccBillStatusData(NccBillStatus entity)
    {
        startPage();
        return getDataTable(billStatusService.findNccBillStatusData(entity));
    }

    /**
     * 根据pK_STORESTATE修改单据信息
     * @Author wangzhichao
     * @Date 2024/12/10 17:00:40
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:stateEdit')")
    @PutMapping("nccBillStatusUpdate")
    @LogC(title = "ncc单据状态信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_bill_status", pkFieldNames = "id", content = "' 单据名称：'+#entity.vname")
    public AjaxResult nccBillStatusUpdate(@RequestBody NccBillStatus entity){
        return billStatusService.nccBillStatusUpdate(entity);
    }

    /**
     * 新增单据信息
     * @Author wangzhichao
     * @Date 2024/12/11 09:47:12
     * @Param entity
     */
    @ApiOperation("新增接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:add')")
    @PostMapping("nccBillStatusSave")
    @LogC(title = "ncc单据状态信息", businessType = BusinessType.INSERT,
            tableNames = "ncc_bill_status", pkFieldNames = "id", content = "' 单据名称：'+#entity.vname")
    public AjaxResult nccBillStatusSave(@RequestBody NccBillStatus entity){
        return billStatusService.nccBillStatusSave(entity);
    }

    /**
     * 根据名称模糊查询单据名称列表
     * @param name
     * @return
     */
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBillstatusName")
    public List<String> findNccBillstatusName(String name){
        return billStatusService.findNccBillstatusName(name);
    }

    /**
     * 定时同步单据状态
     * @return
     */
    @GetMapping("billStatus/jobMethod")
    public R jobMethodExecute()
    {
        return billStatusService.jobMethodExecute(false);
    }

    /**
     * 获取单据状态列表
     */
    @GetMapping("billStatus/list")
    public AjaxResult billStatusList(String name)
    {
        List<HashMap> list = billStatusService.list(name);
        return AjaxResult.success(list);
    }

}
